import {
	http,
	Method
} from "@/utils/request.js";

import api from "@/config/api.js";

/**
 * 重启聊天
 * @param {*} gameId 
 * @param {*} storyId 
 * @param {*} agentId 
 * @returns
 */
export function reloadChat(params) {
	return http.request({
		url: `/chat/reload`,
		method: Method.GET,
		params
	});
}


/**
 * 异步获取语音base64数据
 * @param {*} messageId
 * @returns
 */
export function getVoiceApi(messageId) {
	return http.request({
		url: `/chat/message/read/${messageId}`,
		method: Method.GET,
	});
}



/**
 * 根据gameId和storyId获取talkId 
 */
export function getTalkByGameAndStory(params) {
	return http.request({
		url: `/talk/agent/talk`,
		method: Method.GET,
		params
	});
}

/**
 * 根据agentId生成talkId 
 * @param {*} agentId 
 * @returns 
 */
export function getTalkByUser(agentId) {
	return http.request({
		url: `/talk/agent/${agentId}`,
		method: Method.GET,
	});
}

/**
 * 发送消息
 * @param {*} payload 参数内容 
 * @returns 
 */
export function sendMessageApi(payload) {
	return http.request({
		url: `/chat/message`,
		method: Method.POST,
		data: payload
	});
}


/**
 * 预先发送消息进行预加载
 * @param {*} payload 参数内容 
 * @returns 
 */
export function sendPreMessageApi(payload) {
	return http.request({
		url: `/chat/preTalk`,
		method: Method.POST,
		data: payload
	});
}

/**
 * 获取聊天列表 
 * @param {*} talkId 
 * @returns 
 */
export function getTalkList(params) {
	return http.request({
		url: `/chat/list`,
		method: Method.GET,
		params
	});
}

/**
 * 获取聊天记录信息接口
 * @param {*} params 
 * @returns 
 */
export function getTalkMessage(params) {
	return http.request({
		url: `/chat/message/list`,
		method: Method.GET,
		params
	});
}


// 从商品页点击 客服 跳转 获取商品详情
export function jumpObtain(skuId, goodsId) {
	return http.request({
		url: `/goods/goods/sku/${goodsId}/${skuId}`,
		method: Method.GET,
	});
}
